Leadtools.Medical.Workstation.DataAccessLayer Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
DicomInformation Class
See Also  Members   Example 
Leadtools.Medical.Workstation.DataAccessLayer Namespace : DicomInformation Class



A strongly typed DataSet which contains tables representing the DICOM Database schema.

Syntax

Visual Basic (Declaration)  
<XmlSchemaProviderAttribute(MethodName="GetTypedDataSetSchema", IsAny=False)>
<ToolboxItemAttribute(ToolboxItemType=System.Drawing.Design.ToolboxItem, ToolboxItemTypeName="System.Drawing.Design.ToolboxItem, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>
<HelpKeywordAttribute("vs.data.DataSet")>
<GeneratedCodeAttribute(Tool="System.Data.Design.TypedDataSetGenerator", Version="2.0.0.0")>
<DesignerCategoryAttribute("code")>
<XmlRootAttribute("DicomInformation")>
<SerializableAttribute()>
Public Class DicomInformation 
   Inherits DataSet
Visual Basic (Usage) Copy Code
Dim instance As DicomInformation
C#  
[XmlSchemaProviderAttribute(MethodName="GetTypedDataSetSchema", IsAny=false)]
[ToolboxItemAttribute(ToolboxItemType=System.Drawing.Design.ToolboxItem, ToolboxItemTypeName="System.Drawing.Design.ToolboxItem, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[HelpKeywordAttribute("vs.data.DataSet")]
[GeneratedCodeAttribute(Tool="System.Data.Design.TypedDataSetGenerator", Version="2.0.0.0")]
[DesignerCategoryAttribute("code")]
[XmlRootAttribute("DicomInformation")]
[SerializableAttribute()]
public class DicomInformation : DataSet 
C++/CLI  
[XmlSchemaProviderAttribute(MethodName="GetTypedDataSetSchema", IsAny=false)]
[ToolboxItemAttribute(ToolboxItemType=System.Drawing.Design.ToolboxItem, ToolboxItemTypeName="System.Drawing.Design.ToolboxItem, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[HelpKeywordAttribute("vs.data.DataSet")]
[GeneratedCodeAttribute(Tool="System.Data.Design.TypedDataSetGenerator", Version="2.0.0.0")]
[DesignerCategoryAttribute("code")]
[XmlRootAttribute("DicomInformation")]
[SerializableAttribute()]
public ref class DicomInformation : public DataSet 

Example

Visual Basic Copy Code
<Test> _
Public Sub StoreDICOMImages()
  Dim dataSet As DicomDataSet = New DicomDataSet()
  Dim dataSetPath As String = Path.Combine (ImagesPath.Path, "IMAGE1.DIC")

  dataSet.Load (dataSetPath, DicomDataSetLoadFlags.LoadAndClose)

  Dim thumbnailPath As String = GenerateThumbnail (dataSet)

  Dim dataAccessAgent As IWorkstationDataAccessAgent = Nothing
  Try
     'make sure you have configured the application configuration file with a valid
     'SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection'
     dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent ("WorkstationSqlCeConnection")

     If Nothing Is dataAccessAgent Then
       Console.WriteLine ("You have not configured a valid database connection.")

       Return
     End If
  Catch exception As Exception
     Console.WriteLine(exception.Message," :You have not configured a valid database connection.")

     Return
  End Try

  dataAccessAgent.AddDicom (dataSet, "TEST", dataSetPath,thumbnailPath)

  'perform a wildcard query for all the database information.
  Dim queryResult As DicomInformation = dataAccessAgent.QueryDicomInformation (New FindQuery ())


  If queryResult.Images.Count > 0 Then
     Console.WriteLine (queryResult.Images (0).SOPInstanceUID)

     dataAccessAgent.RemoveDicom (queryResult.Images)
  Else
     Console.WriteLine ("No images found in the database.")
  End If
End Sub

Private Function GenerateThumbnail(ByVal dataset As DicomDataSet) As String
  Dim codec As RasterCodecs = New RasterCodecs()

  Dim imageElement As DicomElement = dataset.FindFirstElement(Nothing, DicomTag.PixelData, False)

  If Not Nothing Is imageElement Then
     Dim rasterImage As RasterImage
     Dim resizeCmd As SizeCommand
     Dim thumbImage As String

     rasterImage = dataset.GetImage(imageElement, 0, 0, RasterByteOrder.Rgb, DicomGetImageFlags.AutoApplyModalityLut Or DicomGetImageFlags.AutoApplyVoiLut)

     If rasterImage.Signed OrElse rasterImage.GrayscaleMode = RasterGrayscaleMode.OrderedInverse Then
       Dim cmgGray As GrayscaleCommand

       cmgGray = New GrayscaleCommand(8)

       cmgGray.Run(rasterImage)
     End If

     resizeCmd = New SizeCommand(64, 64, RasterSizeFlags.None)

     resizeCmd.Run(rasterImage)

     thumbImage = Path.Combine (ImagesPath.Path, "Test.jpg")

     codec.Save(rasterImage, thumbImage, RasterImageFormat.Jpeg, 24)

     Return thumbImage
  Else
     Return Nothing
  End If
End Function
C# Copy Code
public void StoreDICOMImages ( )  

   DicomDataSet dataSet = new DicomDataSet(); 
 
   string dataSetPath = Path.Combine ( ImagesPath.Path, "IMAGE1.DIC" ) ; 
 
   dataSet.Load ( dataSetPath, DicomDataSetLoadFlags.LoadAndClose ) ; 
 
   string thumbnailPath = GenerateThumbnail ( dataSet ) ; 
 
   IWorkstationDataAccessAgent dataAccessAgent = null ; 
   try 
   { 
      //make sure you have configured the application configuration file with a valid  
      //SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection' 
      dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent ( "WorkstationSqlCeConnection" ) ; 
 
      if ( null == dataAccessAgent ) 
      { 
         Console.WriteLine ( "You have not configured a valid database connection." ) ; 
 
         return ; 
      } 
   } 
   catch ( Exception exception ) 
   { 
      Console.WriteLine( exception.Message," :You have not configured a valid database connection."); 
 
      return ; 
   } 
 
   dataAccessAgent.AddDicom ( dataSet, "TEST", dataSetPath,thumbnailPath ) ; 
 
   //perform a wildcard query for all the database information. 
   DicomInformation queryResult = dataAccessAgent.QueryDicomInformation ( new FindQuery ( ) ) ; 
 
 
   if ( queryResult.Images.Count > 0 )  
   { 
      Console.WriteLine ( queryResult.Images [ 0 ].SOPInstanceUID ) ; 
 
      dataAccessAgent.RemoveDicom ( queryResult.Images ) ; 
   } 
   else 
   { 
      Console.WriteLine ( "No images found in the database." ); 
   } 

 
private string GenerateThumbnail 

   DicomDataSet dataset 
 


   RasterCodecs codec = new RasterCodecs(); 
 
   DicomElement imageElement = dataset.FindFirstElement(null, DicomTag.PixelData, false); 
 
   if (null != imageElement) 
   { 
      RasterImage rasterImage; 
      SizeCommand resizeCmd; 
      string thumbImage; 
 
      rasterImage = dataset.GetImage(imageElement, 
                                       0, 
                                       0, 
                                       RasterByteOrder.Rgb, 
                                       DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut); 
 
      if (rasterImage.Signed || rasterImage.GrayscaleMode == RasterGrayscaleMode.OrderedInverse) 
      { 
         GrayscaleCommand cmgGray; 
 
         cmgGray = new GrayscaleCommand(8); 
 
         cmgGray.Run(rasterImage); 
      } 
 
      resizeCmd = new SizeCommand(64, 64, RasterSizeFlags.None); 
 
      resizeCmd.Run(rasterImage); 
 
      thumbImage = Path.Combine ( ImagesPath.Path, "Test.jpg" ) ; 
 
      codec.Save(rasterImage, thumbImage, RasterImageFormat.Jpeg, 24); 
 
      return thumbImage ; 
   } 
   else 
   { 
      return null ; 
   } 
}

Remarks

This class inherits from the DataSet class to define the tables and relations which represent how the DICOM information is stored and retrieved.

The DicomInformation class contains four strongly typed tables:

Each DataTable is related to another table with a foreign key relationship.

The DicomInformation.StudiesDataTable has a foreign key relation with the DicomInformation.PatientsDataTable using the DicomInformation.StudiesDataTable.PatientIDColumn column.

The DicomInformation.SeriesDataTable has a foreign key relation with the DicomInformation.StudiesDataTable using the DicomInformation.SeriesDataTable.StudyInstanceUIDColumn column.

The DicomInformation.ImagesDataTable has a foreign key relation with the DicomInformation.SeriesDataTable using the DicomInformation+ImagesDataTable.SeriesInstanceUIDColumn column.

Inheritance Hierarchy

System.Object
   System.ComponentModel.MarshalByValueComponent
      System.Data.DataSet
         Leadtools.Medical.Workstation.DataAccessLayer.DicomInformation

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Leadtools.Medical.Workstation.DataAccessLayer requires a Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features