Skip to content

Commit

Permalink
Add configuration more suitable to DSA.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Oct 10, 2023
1 parent f3eec6a commit 8f2ebb0
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 7 deletions.
3 changes: 3 additions & 0 deletions slicer_cli_plugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ RUN pip3 install --upgrade pip
RUN pip3 install -r /opt/HistoQC/requirements.txt
RUN pip3 install girder-slicer-cli-web girder-client
RUN pip3 install large-image[all] --find-links https://girder.github.io/large_image_wheels
# HistoQC doesn't work with PIL 10
RUN pip3 install 'Pillow<10'

COPY . $PWD
RUN cp config_dsa.ini /opt/HistoQC/histoqc/config/.

ENTRYPOINT ["python3", "./cli_list.py"]
19 changes: 13 additions & 6 deletions slicer_cli_plugin/HistoQC/HistoQC.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
girder = girder_client.GirderClient(apiUrl=args.girderApiUrl)
girder.setToken(args.girderToken)

conf = open('/opt/HistoQC/histoqc/config/config.ini').read()
conf = conf.replace('confirm_base_mag: False', 'confirm_base_mag: False\nbase_mag: 20')
conf = open('/opt/HistoQC/histoqc/config/config.ini', 'w').write(conf)

confpath = '/opt/HistoQC/histoqc/config/' + args.config
if os.path.exists(confpath):
conf = open(confpath).read()
if '\nbase_mag' not in conf:
logging.info('Adding base_mag to %s', confpath)
conf = conf.replace('confirm_base_mag: False', 'confirm_base_mag: False\nbase_mag: 20')
conf = open(confpath, 'w').write(conf)
else:
confpath = None

input_dir = args.inputDir
logging.info(f'{input_dir = }')
Expand Down Expand Up @@ -97,11 +102,13 @@

os.chdir(histoqc_dir)

histoqc_output = subprocess.check_output([
cmd = [
"python3", "-m", "histoqc",
'-o', tmp_output_dir,
f'{input_dir}/*'
])
] + (['-c', confpath] if confpath else [])
logging.info('Running %r', cmd)
histoqc_output = subprocess.check_output(cmd)

os.chdir(current_dir)

Expand Down
2 changes: 1 addition & 1 deletion slicer_cli_plugin/HistoQC/HistoQC.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<longflag>--config</longflag>
<description><![CDATA[Configuration file to use, defaults to config.ini for H&E images]]></description>
<label>config</label>
<default>config.ini</default>
<default>config_dsa.ini</default>
</string>

</parameters>
Expand Down
217 changes: 217 additions & 0 deletions slicer_cli_plugin/config_dsa.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
[pipeline]
steps= BasicModule.getBasicStats
ClassificationModule.byExampleWithFeatures:pen_markings
ClassificationModule.byExampleWithFeatures:coverslip_edge
LightDarkModule.getIntensityThresholdPercent:tissue
LightDarkModule.getIntensityThresholdPercent:darktissue
BubbleRegionByRegion.detectSmoothness
MorphologyModule.removeFatlikeTissue
MorphologyModule.fillSmallHoles
MorphologyModule.removeSmallObjects
BlurDetectionModule.identifyBlurryRegions
BasicModule.finalProcessingSpur
BasicModule.finalProcessingArea
HistogramModule.compareToTemplates
HistogramModule.getHistogram
BrightContrastModule.getContrast
BrightContrastModule.getBrightnessGray
BrightContrastModule.getBrightnessByChannelinColorSpace:RGB
BrightContrastModule.getBrightnessByChannelinColorSpace:YUV
BrightContrastModule.getContrast:background
BrightContrastModule.getBrightnessGray:background
BrightContrastModule.getBrightnessByChannelinColorSpace:RGB:background
DeconvolutionModule.separateStains
SaveModule.saveFinalMask
SaveModule.saveMacro
SaveModule.saveThumbnails
BasicModule.finalComputations


[BaseImage.BaseImage]
image_work_size = 1.25x

#not yet implemented
confirm_base_mag: False
base_mag: 20

#three options: relative2mask, absolute, relative2image
mask_statistics = relative2mask

[BasicModule.getBasicStats]
image_work_size = 1.25x

#[ClassificationModule.byExample]
[ClassificationModule.byExampleWithFeatures:pen_markings]
name: pen_markings
threshold: .5
examples: ./pen/1k_version/pen_green.png:./pen/1k_version/pen_green_mask.png

area_threshold: 100
features: frangi
laplace
rgb
#lbp
#gabor
#median
#gaussian

laplace_ksize: 3

frangi_scale_range: (1,10)
frangi_scale_step: 2
frangi_beta1: .5
frangi_beta2: 15
frangi_black_ridges: True

gabor_theta: 4
gabor_sigma: (1,3)
gabor_frequency: (0.05, 0.25)

lbp_radius: 3
lbp_points: 24
lbp_method: default

median_disk_size: 3

#gaussian_sigma: 1
#gaussian_multichan: False



[ClassificationModule.byExampleWithFeatures:coverslip_edge]
name: coverslip_edge
threshold: .5

examples: ./models/coverslip_edge_he/coverslip_edge.png:./models/coverslip_edge_he/coverslip_edge_mask.png

area_threshold: 15
features: frangi
laplace
rgb

dilate_kernel_size: 5

[LightDarkModule.getIntensityThresholdPercent:bubble]
name: bubble
upper_threshold: .94
lower_threshold: .82
upper_variance: 11
invert: true


[LightDarkModule.getIntensityThresholdPercent:tissue]
name: bright
upper_threshold: .9
lower_std: 10

[LightDarkModule.getIntensityThresholdPercent:darktissue]
name: dark
upper_threshold: .15
invert: true


[LightDarkModule.getTissuePercent]
threshold: .8

[LightDarkModule.getDarkTissuePercent]
threshold: .15

[MorphologyModule.removeSmallObjects]
min_size: 64

[MorphologyModule.removeFatlikeTissue]
kernel_size: 10
max_keep_size: 1000
fat_cell_size: 64

[MorphologyModule.fillSmallHoles]
min_size: 1000

[HistogramModule.compareToTemplates]
limit_to_mask: True
bins: 20
templates= ./templates/template1.png
./templates/template2.png
./templates/template3.png
./templates/template4.png

[HistogramModule.getHistogram]
limit_to_mask: True
bins: 20

[BrightContrastModule.getContrast]
limit_to_mask: True


[BrightContrastModule.getBrightnessGray]
limit_to_mask: True

[BrightContrastModule.getBrightnessByChannelinColorSpace:RGB]
limit_to_mask: True


[BrightContrastModule.getBrightnessByChannelinColorSpace:YUV]
limit_to_mask: True
#pick a color space in the list from 'RGB', 'HSV', 'RGB CIE', 'XYZ', 'YUV', 'YIQ', 'YPbPr', 'YCbCr' : http://scikit-image.org/docs/dev/api/skimage.color.html#skimage.color.convert_colorspace
to_color_space: YUV

[BrightContrastModule.getContrast:background]
limit_to_mask: True
invert: True
prefix: background

[BrightContrastModule.getBrightnessGray:background]
limit_to_mask: True
invert: True
prefix: background

[BrightContrastModule.getBrightnessByChannelinColorSpace:RGB:background]
limit_to_mask: True
invert: True
prefix: background

[SaveModule.saveFinalMask]
overlay: True

[SaveModule.saveMacro]
dim: 500

[SaveModule.saveThumbnails]
image_work_size: 1.25x
small_dim: 500

[BlurDetectionModule.identifyBlurryRegions]
image_work_size = 2.5x
blur_radius: 100
blur_threshold: .05


[BasicModule.finalComputations]

[BasicModule.finalProcessingSpur]
disk_radius: 5

[BasicModule.finalProcessingArea]
#area_threshold: 90000
area_threshold: 10000

[DeconvolutionModule.separateStains]
;hed_from_rgb: Hematoxylin + Eosin + DAB
;hdx_from_rgb: Hematoxylin + DAB
;fgx_from_rgb: Feulgen + Light Green
;bex_from_rgb: Giemsa stain : Methyl Blue + Eosin
;rbd_from_rgb: FastRed + FastBlue + DAB
;gdx_from_rgb: Methyl Green + DAB
;hax_from_rgb: Hematoxylin + AEC
;bro_from_rgb: Blue matrix Anilline Blue + Red matrix Azocarmine + Orange matrix Orange-G
;bpx_from_rgb: Methyl Blue + Ponceau Fuchsin
;ahx_from_rgb: Alcian Blue + Hematoxylin
;hpx_from_rgb: Hematoxylin + PAS
stain: hed_from_rgb
use_mask: True


[BubbleRegionByRegion.detectSmoothness]
threshold: .01
kernel_size: 10
min_object_size: 500

0 comments on commit 8f2ebb0

Please sign in to comment.