Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openslide converter #23

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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