Skip to content

Commit

Permalink
Merge pull request #23 from mc2-center/openslide-converter
Browse files Browse the repository at this point in the history
Add openslide converter
  • Loading branch information
adamjtaylor authored Nov 29, 2023
2 parents fa53aa7 + 514c911 commit 9ff12c5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
9 changes: 9 additions & 0 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ nextflow.enable.dsl=2

if (params.input) { params.input = file(params.input) } else { exit 1, 'Input samplesheet not specified!' }

params.convert = false

if (params.convert) {
if (!params.mag || !params.mpp) {
error "Both nominal magnification ('mag') and microns per pixel ('mpp' parameters must be provided when 'params.convert' is set to true."
}
}


// Set parameters and defaults
params.outDir = './outputs'
params.config = 'default'
Expand Down
17 changes: 17 additions & 0 deletions modules/convert_to_openslide.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
process CONVERT {

container 'ghcr.io/mc2-center/histoqc-openslide-converter:latest'

input:
tuple val(meta), path(images)

output:
tuple val(meta), path("${images.simpleName}_openslide.tiff")

script:

"""
vips im_vips2tiff $images ${images.simpleName}_openslide.tiff:jpeg:75,tile:512x512,pyramid
tifftools set -y -s ImageDescription "Aperio nf-histoqc |AppMag = $params.mag|MPP = $params.mpp" ${images.simpleName}_openslide.tiff
"""
}
23 changes: 23 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@
"enum": ["default", "ihc", "clinical", "first", "light", "v2.1"]
}
}
},
"conversion_options": {
"title": "Conversion options",
"type": "object",
"fa_icon": "fas fa-solid fa-magic",
"description": "Define parameters used during conversion to openslide compatible tiff",
"properties": {
"convert": {
"type": "boolean",
"description": "Should images be converted to an openslide compatible tiff",
"hidden": true
},
"mag": {
"type": "integer",
"description": "Nominal magnification to inject into openslide compatible tiff",
"hidden": true
},
"mpp": {
"type": "number",
"description": "Image resolution (microns per pixel) to inject into openslide compatible tiff",
"hidden": true
}
}
}
},
"allOf": [
Expand Down
4 changes: 3 additions & 1 deletion subworkflows/run_histoqc.nf
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
include { HISTOQC } from "../modules/histoqc.nf"
include { CONVERT } from "../modules/convert_to_openslide.nf"

workflow RUN {

take:
images

main:
HISTOQC ( images )

params.convert ? CONVERT(images) | HISTOQC : HISTOQC(images)

emit:
output = HISTOQC.out.masks
Expand Down

0 comments on commit 9ff12c5

Please sign in to comment.