Australian-Imaging-Service / pipelines

Scripts to generate analysis pipelines that can be run in XNAT's container service
Other
2 stars 3 forks source link

[STORY] Convert svs to dcm. #329

Open anzhao opened 1 month ago

anzhao commented 1 month ago

Topic

Convert whole slide image to DICOM files Using the WsiDicomizer library

Solution

from turbojpeg import TurboJPEG
from wsidicomizer import WsiDicomizer
input_file = '626582.svs'
output_file = './anzhao/'
turbojpeg_path = '/usr/lib/x86_64-linux-gnu/libturbojpeg.so.0'
jpeg = TurboJPEG(turbojpeg_path)
WsiDicomizer.convert(input_file, output_file)                                           

Output

an@ip-10-0-11-188:~/Downloads/anzhao$ ls
1.2.826.0.1.3680043.8.498.11385258866588262240359721690554906552.dcm
1.2.826.0.1.3680043.8.498.12849624007597803127156563897779778086.dcm
1.2.826.0.1.3680043.8.498.14880212369891852710606249615246259404.dcm
1.2.826.0.1.3680043.8.498.25850281822407255183436927373102014363.dcm
1.2.826.0.1.3680043.8.498.33539753497614587757353834061696309093.dcm
1.2.826.0.1.3680043.8.498.56552714980520408482426857287295288068.dcm
anzhao commented 1 month ago

The sample slide image contains Aperio, OpenSlide and TIFF Metadata respectively:

  1. Aperio Metadata:

aperio.AppMag: 40 aperio.DSR ID: 118.138.243.122 aperio.Date: 07/25/24 aperio.DisplayColor: 0 aperio.Exposure Scale: 0.000001 aperio.Exposure Time: 109 aperio.Filename: 626582 aperio.Filtered: 5 aperio.Focus Offset: 0.000000 aperio.ICC Profile: ScanScope v1 aperio.ImageID: 626582 aperio.Left: 13.453889 aperio.LineAreaXOffset: 0.002546 aperio.LineAreaYOffset: -0.000922 aperio.LineCameraSkew: -0.000807 aperio.MPP: 0.2483 aperio.OriginalHeight: 88846 aperio.OriginalWidth: 162560 aperio.ScanScope ID: SS1681 aperio.SessonMode: NR aperio.StripeWidth: 2032 aperio.Time: 09:14:57 aperio.Time Zone: GMT+10:00 aperio.Top: 23.085934 aperio.User: 00000000-0000-0000-0000-000000000000

  1. OpenSlide Metadata:

openslide.comment: Aperio Image Library v12.0.15 162560x88846 [0,100 159360x88746] (240x240) J2K/KDU Q=70|AppMag = 40|StripeWidth = 2032|ScanScope ID = SS1681|Filename = 626582|Date = 07/25/24|Time = 09:14:57|Time Zone = GMT+10:00|User = 00000000-0000-0000-0000-000000000000|MPP = 0.2483|Left = 13.453889|Top = 23.085934|LineCameraSkew = -0.000807|LineAreaXOffset = 0.002546|LineAreaYOffset = -0.000922|Focus Offset = 0.000000|DSR ID = 118.138.243.122|ImageID = 626582|Exposure Time = 109|Exposure Scale = 0.000001|DisplayColor = 0|SessonMode = NR|OriginalWidth = 162560|OriginalHeight = 88846|Filtered = 5|ICC Profile = ScanScope v1 openslide.level-count: 4 openslide.level[0].downsample: 1 openslide.level[0].height: 88746 openslide.level[0].tile-height: 240 openslide.level[0].tile-width: 240 openslide.level[0].width: 159360 openslide.level[1].downsample: 4.0000450734697557 openslide.level[1].height: 22186 openslide.level[1].tile-height: 240 openslide.level[1].tile-width: 240 openslide.level[1].width: 39840 openslide.level[2].downsample: 16.000901550667148 openslide.level[2].height: 5546 openslide.level[2].tile-height: 240 openslide.level[2].tile-width: 240 openslide.level[2].width: 9960 openslide.level[3].downsample: 64.015151515151516 openslide.level[3].height: 1386 openslide.level[3].tile-height: 240 openslide.level[3].tile-width: 240 openslide.level[3].width: 2490 openslide.mpp-x: 0.24829999999999999 openslide.mpp-y: 0.24829999999999999 openslide.objective-power: 40 openslide.quickhash-1: ea4d53207758c82455de9095077fbb5cc23c7cc3a483c559deeb379483f5b6eb openslide.vendor: aperio

  1. TIFF Metadata:

tiff.ImageDescription: Aperio Image Library v12.0.15 162560x88846 [0,100 159360x88746] (240x240) J2K/KDU Q=70|AppMag = 40|StripeWidth = 2032|ScanScope ID = SS1681|Filename = 626582|Date = 07/25/24|Time = 09:14:57|Time Zone = GMT+10:00|User = 00000000-0000-0000-0000-000000000000|MPP = 0.2483|Left = 13.453889|Top = 23.085934|LineCameraSkew = -0.000807|LineAreaXOffset = 0.002546|LineAreaYOffset = -0.000922|Focus Offset = 0.000000|DSR ID = 118.138.243.122|ImageID = 626582|Exposure Time = 109|Exposure Scale = 0.000001|DisplayColor = 0|SessonMode = NR|OriginalWidth = 162560|OriginalHeight = 88846|Filtered = 5|ICC Profile = ScanScope v1 tiff.ResolutionUnit: inch

anzhao commented 1 month ago

Set up the container service plugin with wsi to dicom convert tool:

Image

Image

anzhao commented 1 week ago

Provide two solutions to convert whole slide image to DICOM files: