LEADTOOLS Medical (Leadtools.Medical.Workstation.Loader assembly)
LEAD Technologies, Inc

FindSeriesCells Method

Example 





The Series Instance UID of the series to search for the Leadtools.MedicalViewer.MedicalViewerMultiCell.
Returns an array of Leadtools.MedicalViewer.MedicalViewerMultiCell controls which the provided series is loaded in.
Syntax
public MedicalViewerMultiCell[] FindSeriesCells( 
   string seriesInstanceUID
)
'Declaration
 
Public Function FindSeriesCells( _
   ByVal seriesInstanceUID As String _
) As MedicalViewerMultiCell()
'Usage
 
Dim instance As MedicalViewerLoaderBase
Dim seriesInstanceUID As String
Dim value() As MedicalViewerMultiCell
 
value = instance.FindSeriesCells(seriesInstanceUID)
public MedicalViewerMultiCell[] FindSeriesCells( 
   string seriesInstanceUID
)
 function Leadtools.Medical.Workstation.Loader.MedicalViewerLoaderBase.FindSeriesCells( 
   seriesInstanceUID 
)
public:
array<MedicalViewerMultiCell^>^ FindSeriesCells( 
   String^ seriesInstanceUID
) 

Parameters

seriesInstanceUID
The Series Instance UID of the series to search for the Leadtools.MedicalViewer.MedicalViewerMultiCell.
Example
 
Private viewer As New MedicalViewer()

         Public Sub LoadSeries()
#If LEADTOOLS_V175_OR_LATER Then
                Leadtools.Examples.Support.SetLicense()
#Else
         Leadtools.Examples.Support.Unlock()
#End If ''' #if LEADTOOLS_V175_OR_LATER

            Dim clientInfo As New AeInfo()

            clientInfo.Address = Dns.GetHostName()
            clientInfo.Port = 1000
            clientInfo.AETitle = "TEST_CLIENT"

            Dim serverInfo As New DicomScp()
            serverInfo.AETitle = "LEAD_SERVER"
            serverInfo.Port = 104
            serverInfo.PeerAddress = GetLocalServerAddress()
            serverInfo.Timeout = 30

            Dim queryClient As New PacsQueryClient(clientInfo, serverInfo)

            Dim queryResult() As DicomDataSet = queryClient.FindSeries(New FindQuery())

            If queryResult.Length > 0 Then
               Dim retrieveClient As New PacsRetrieveClient(clientInfo, serverInfo)


               'make sure you have configured the workstation database correctly for the PacsRetrieveClient to store the images.
               retrieveClient.StoreRetrievedImages = True 'we want to store the images locally so we can view them later.

               Dim loader As New MedicalViewerLoader(retrieveClient)

               loader.ViewerControl = viewer
               loader.Layout.Auto = True
               loader.LazyLoading = True 'this will cause to load the images for displayed sub-cells only
               loader.ViewerPreLoadedImages = 1 'this will allow to load 1 image after and before the displayed sub-cell for fast scrolling.

               AddHandler loader.ProgressState, AddressOf loader_ProgressState
               AddHandler loader.RequestedImageUpdated, AddressOf loader_RequestedImageUpdated

               Dim studyInstanceUID As String = queryResult(0).GetValue(Of String)(DicomTag.StudyInstanceUID, String.Empty)
               Dim seriesInstanceUID As String = queryResult(0).GetValue(Of String)(DicomTag.SeriesInstanceUID, String.Empty)

               If loader.LoadSeries(studyInstanceUID, seriesInstanceUID) Then
                  Console.WriteLine("Number of viewer cells: {0}", viewer.Cells.Count)
                  Console.WriteLine("Number of loader created cells: {0}", loader.SeriesCells.Length)

                  For Each cell As MedicalViewerMultiCell In loader.FindSeriesCells(seriesInstanceUID)
                     Dim sopInstanceUID As String = loader.FindDisplayedCellInstanceInformation(cell, 0).SOPInstanceUID

                     Console.WriteLine("Cell #{0} has first image with SOPInstanceUID={1}", viewer.Cells.IndexOf(cell), sopInstanceUID)


                     Dim ds As DicomDataSet = loader.GetDicom(sopInstanceUID)
                     Dim imageElement As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PixelData, True)

                     If Nothing IsNot imageElement AndAlso imageElement.Length > 0 Then
                        Using codec As New RasterCodecs()
                           Using image As RasterImage = ds.GetImage(imageElement, 0, 24, RasterByteOrder.Gray, DicomGetImageFlags.AutoApplyModalityLut Or DicomGetImageFlags.AutoApplyVoiLut)
                              codec.Save(image, Path.Combine(LEAD_VARS.ImagesDir, sopInstanceUID), RasterImageFormat.Jpeg, image.BitsPerPixel)

                              Console.WriteLine("Image with SOPInstanceUID={0} saved to {1}", sopInstanceUID, Path.Combine(LEAD_VARS.ImagesDir, sopInstanceUID))
                           End Using
                        End Using
                     End If

                     Dim imagesPath() As String = loader.GetSeriesImages(cell)

                     Console.WriteLine("Cell #{0} is loaded from {1} file(s):", viewer.Cells.IndexOf(cell), imagesPath.Length)

                     For Each imagePath As String In imagesPath
                        Console.WriteLine(imagesPath)
                     Next imagePath
                  Next cell
               End If

               loader.Close()
            End If
         End Sub

         Private Sub loader_RequestedImageUpdated(ByVal sender As Object, ByVal e As RequestedImageUpdatedEventArgs)
            Console.WriteLine("Image streamer for cell {0}, sub-cell {1}", viewer.Cells.IndexOf(e.Cell), e.SubCellIndex)
         End Sub

         Private Sub loader_ProgressState(ByVal sender As Object, ByVal e As ProgressEventArgs)
            Console.WriteLine(e.Message)
         End Sub

         Public Function GetLocalServerAddress() As IPAddress
            Dim addresses() As IPAddress

            'you can use any IP address which a DICOM server is listning to.
            addresses = Dns.GetHostAddresses(Dns.GetHostName())

            For Each address As IPAddress In addresses
               If address.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then
                  Return address
               End If
            Next address

            Throw New InvalidOperationException("No IP Address V4 found for this machine.")
         End Function

   Public NotInheritable Class LEAD_VARS
      Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
   End Class
MedicalViewer viewer = new MedicalViewer();

         public void LoadSeries ( ) 
         {
#if LEADTOOLS_V175_OR_LATER
            Leadtools.Examples.Support.SetLicense();
#else
            Leadtools.Examples.Support.Unlock();
#endif // #if LEADTOOLS_V175_OR_LATER

            AeInfo clientInfo = new AeInfo ( ) ;

            clientInfo.Address = Dns.GetHostName () ;
            clientInfo.Port = 1000 ;
            clientInfo.AETitle = "TEST_CLIENT" ;

            DicomScp serverInfo = new DicomScp ( ) ;
            serverInfo.AETitle = "LEAD_SERVER" ;
            serverInfo.Port = 104 ;
            serverInfo.PeerAddress = GetLocalServerAddress ()  ;
            serverInfo.Timeout = 30 ;

            PacsQueryClient queryClient = new PacsQueryClient ( clientInfo, serverInfo ) ;

            DicomDataSet[] queryResult =  queryClient.FindSeries ( new FindQuery ( ) ) ;

            if ( queryResult.Length > 0 ) 
            {
               PacsRetrieveClient retrieveClient = new PacsRetrieveClient(clientInfo, serverInfo);


               //make sure you have configured the workstation database correctly for the PacsRetrieveClient to store the images.
               retrieveClient.StoreRetrievedImages = true ; //we want to store the images locally so we can view them later.

               MedicalViewerLoader loader = new MedicalViewerLoader(retrieveClient );

               loader.ViewerControl = viewer ;
               loader.Layout.Auto = true ;
               loader.LazyLoading = true ; //this will cause to load the images for displayed sub-cells only
               loader.ViewerPreLoadedImages = 1; //this will allow to load 1 image after and before the displayed sub-cell for fast scrolling.

               loader.ProgressState += new ProgressEventHandler(loader_ProgressState);
               loader.RequestedImageUpdated += new EventHandler<RequestedImageUpdatedEventArgs>(loader_RequestedImageUpdated);

               string studyInstanceUID = queryResult [ 0 ].GetValue <string> ( DicomTag.StudyInstanceUID, string.Empty) ;
               string seriesInstanceUID = queryResult[ 0 ].GetValue <string> ( DicomTag.SeriesInstanceUID, string.Empty )  ;

               if ( loader.LoadSeries ( studyInstanceUID, seriesInstanceUID )  )
               {
                  Console.WriteLine ( "Number of viewer cells: {0}",  viewer.Cells.Count ) ;
                  Console.WriteLine ( "Number of loader created cells: {0}",  loader.SeriesCells.Length ) ;

                  foreach ( MedicalViewerMultiCell cell in loader.FindSeriesCells ( seriesInstanceUID ) ) 
                  {
                     string sopInstanceUID = loader.FindDisplayedCellInstanceInformation ( cell, 0 ).SOPInstanceUID ;

                     Console.WriteLine ( "Cell #{0} has first image with SOPInstanceUID={1}", viewer.Cells.IndexOf ( cell ), sopInstanceUID ) ;


                     DicomDataSet ds = loader.GetDicom ( sopInstanceUID ) ;
                     DicomElement imageElement = ds.FindFirstElement ( null, DicomTag.PixelData, true ) ;

                     if ( null != imageElement && imageElement.Length > 0 )
                     {
                        using ( RasterCodecs codec = new RasterCodecs ( ) )
                        {
                           using ( RasterImage image = ds.GetImage ( imageElement, 0, 24, RasterByteOrder.Gray, DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut ) )
                           {
                              codec.Save(image,Path.Combine(LEAD_VARS.ImagesDir,sopInstanceUID), RasterImageFormat.Jpeg, image.BitsPerPixel);

                              Console.WriteLine("Image with SOPInstanceUID={0} saved to {1}", sopInstanceUID,Path.Combine(LEAD_VARS.ImagesDir, sopInstanceUID));
                           }
                        }
                     }

                     string [] imagesPath = loader.GetSeriesImages ( cell ) ;

                     Console.WriteLine ( "Cell #{0} is loaded from {1} file(s):", viewer.Cells.IndexOf ( cell ), imagesPath.Length  ) ;

                     foreach ( string imagePath in imagesPath ) 
                     {
                        Console.WriteLine ( imagesPath ) ;
                     }
                  }
               }

               loader.Close ( ) ;
            }
         }

         void loader_RequestedImageUpdated(object sender, RequestedImageUpdatedEventArgs e)
         {
            Console.WriteLine ( "Image streamer for cell {0}, sub-cell {1}", viewer.Cells.IndexOf ( e.Cell ), e.SubCellIndex )  ;
         }

         void loader_ProgressState(object sender, ProgressEventArgs e)
         {
            Console.WriteLine ( e.Message ) ;
         }

         public IPAddress GetLocalServerAddress ()  
         {
            IPAddress [ ] addresses ;

            //you can use any IP address which a DICOM server is listning to.
            addresses = Dns.GetHostAddresses ( Dns.GetHostName ( ) ) ;

            foreach ( IPAddress address in addresses ) 
            {
               if ( address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ) 
               {
                  return address ;
               }
            }

            throw new InvalidOperationException ( "No IP Address V4 found for this machine." ) ;
         }

   static class LEAD_VARS
   {
      public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
   }
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

MedicalViewerLoaderBase Class
MedicalViewerLoaderBase Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

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