Skip to content
Open
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
7 changes: 7 additions & 0 deletions modules/nf-core/stainwarpy/register/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::stainwarpy=0.2.4
51 changes: 51 additions & 0 deletions modules/nf-core/stainwarpy/register/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
process STAINWARPY_REGISTER {
tag "$meta.id"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/c0/c020e2c9696127244a6a2bbb1d945b9d78c18d3595bac54838e26bddcc87f521/data' :
'community.wave.seqera.io/library/stainwarpy:0.2.4--c8bf19657f01e47a'}"

input:
tuple val(meta), path(hne_img)
tuple val(meta2), path(multiplx_img)
val fixed_img
val final_sz

output:
tuple val(meta), path("*_transformed_image.ome.tif") , emit: reg_image
tuple val(meta), path("*_registration_metrics_tform_map.json") , emit: reg_metrics_tform
tuple val(meta), path("*_feature_based_transformation_map.npy") , emit: tform_map
tuple val("${task.process}"), val('stainwarpy'), eval("stainwarpy --version | sed 's/.* //'"), emit: versions_stainwarpy_register, topic: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
stainwarpy \\
register \\
${multiplx_img} \\
${hne_img} \\
. \\
${fixed_img} \\
${final_sz} \\
${args}

mv 0_final_channel_image.ome.tif ${prefix}_transformed_image.ome.tif
mv registration_metrics_tform_map.json ${prefix}_registration_metrics_tform_map.json
mv feature_based_transformation_map.npy ${prefix}_feature_based_transformation_map.npy
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}_transformed_image.ome.tif
touch ${prefix}_registration_metrics_tform_map.json
touch ${prefix}_feature_based_transformation_map.npy
"""
}
112 changes: 112 additions & 0 deletions modules/nf-core/stainwarpy/register/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: "stainwarpy_register"
description: "Register H&E stained and Multiplexed tissue images using feature-based image registration"
keywords:
- image registration
- histology
- hne
- multiplexed
tools:
- "stainwarpy":
description: "Register H&E stained and Multiplexed tissue images using feature-based image registration"
homepage: "https://github.com/tckumarasekara/stainwarpy"
documentation: "https://github.com/tckumarasekara/stainwarpy"
tool_dev_url: "https://github.com/tckumarasekara/stainwarpy"
licence: ["MIT License", "Apache-2.0"]
identifier: ""

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- hne_img:
type: file
description: H&E stained image file
pattern: "*.{ome.tif,ome.tiff,tif,tiff}"
ontologies:
- edam: "http://edamontology.org/format_3727"
- edam: "http://edamontology.org/format_3591"
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- multiplx_img:
type: file
description: Multiplexed image file
pattern: "*.{ome.tif,ome.tiff,tif,tiff}"
ontologies:
- edam: "http://edamontology.org/format_3727"
- edam: "http://edamontology.org/format_3591"
- fixed_img:
type: string
description: Which image to use as fixed image for registration. Options - 'hne' or 'multiplexed'
ontologies: []
- final_sz:
type: string
description: In which pixel size to output the registered image and segmentation mask. Options - 'hne' or 'multiplexed'
ontologies: []

output:
reg_image:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*_transformed_image.ome.tif":
type: file
description: Registered final channel image in OME-TIFF format
pattern: "*_transformed_image.ome.tif"
ontologies:
- edam: "http://edamontology.org/format_3727"
reg_metrics_tform:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*_registration_metrics_tform_map.json":
type: file
description: Registration metrics and transformation map in JSON format
pattern: "*_registration_metrics_tform_map.json"
ontologies:
- edam: "http://edamontology.org/format_3464"
tform_map:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- "*_feature_based_transformation_map.npy":
type: file
description: Feature-based transformation map in NPY format
pattern: "*_feature_based_transformation_map.npy"
ontologies: []
versions_stainwarpy_register:
- - "${task.process}":
type: string
description: The name of the process
- "stainwarpy":
type: string
description: The name of the tool
- "stainwarpy --version | sed 's/.* //'":
type: eval
description: The expression to obtain the version of the tool

topics:
versions:
- - ${task.process}:
type: string
description: The name of the process
- stainwarpy:
type: string
description: The name of the tool
- stainwarpy --version | sed 's/.* //':
type: eval
description: The expression to obtain the version of the tool
authors:
- "@tckumarasekara"
maintainers:
- "@tckumarasekara"
89 changes: 89 additions & 0 deletions modules/nf-core/stainwarpy/register/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
nextflow_process {

name "Test Process STAINWARPY_REGISTER"
script "../main.nf"
process "STAINWARPY_REGISTER"

tag "modules"
tag "modules_nfcore"
tag "stainwarpy"
tag "stainwarpy/register"

config "./nextflow.config"

test("colon_tissue_local - ome.tif") {

when {
params {
modules_args = "--feature-tform similarity"
}
process {
"""
input[0] = [
[ id:'sample1'],
file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/hne_image_colon.ome.tif', checkIfExists: true)
]
input[1] = [
[ id:'sample1'],
file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/multiplexed_single_channel_img.ome.tif', checkIfExists: true)
]
input[2] = 'multiplexed'
input[3] = 'multiplexed'
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.reg_image.get(0).get(1)).exists(),
file(process.out.reg_metrics_tform.get(0).get(1)).exists(),
file(process.out.tform_map.get(0).get(1)).exists(),
process.out.findAll { key, val -> key.startsWith("versions")}
).match()
}
)
}

}

test("colon_tissue_local - ome.tif - stub") {

options "-stub"

when {
params {
modules_args = null
}
process {
"""
input[0] = [
[ id:'sample1'],
file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/hne_image_colon.ome.tif', checkIfExists: true)
]
input[1] = [
[ id:'sample1'],
file(params.modules_testdata_base_path + 'imaging/hne_multiplexed/multiplexed_single_channel_img.ome.tif', checkIfExists: true)
]
input[2] = 'multiplexed'
input[3] = 'multiplexed'
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.reg_image,
process.out.reg_metrics_tform,
process.out.tform_map,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
)
}
Comment on lines 75 to 85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
then {
{ assert snapshot(
process.out.reg_image,
process.out.reg_metrics_tform,
process.out.tform_map,
process.out.findAll { key, val -> key.startsWith("versions")}
).match() }
}
then {
{ assert snapshot(process.out).match() }
}

This doesn't have the assert process.success?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added assert process.success as suggested. And for the snapshot, snapshotting process.out directly caused nf-test to fail with a “no output channels” error.


}

}
65 changes: 65 additions & 0 deletions modules/nf-core/stainwarpy/register/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"colon_tissue_local - ome.tif": {
"content": [
true,
true,
true,
{
"versions_stainwarpy_register": [
[
"STAINWARPY_REGISTER",
"stainwarpy",
"0.2.4"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.2"
},
"timestamp": "2026-02-11T22:57:25.113779467"
},
"colon_tissue_local - ome.tif - stub": {
"content": [
[
[
{
"id": "sample1"
},
"sample1_transformed_image.ome.tif:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
[
[
{
"id": "sample1"
},
"sample1_registration_metrics_tform_map.json:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
[
[
{
"id": "sample1"
},
"sample1_feature_based_transformation_map.npy:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
{
"versions_stainwarpy_register": [
[
"STAINWARPY_REGISTER",
"stainwarpy",
"0.2.4"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.2"
},
"timestamp": "2026-02-11T22:57:32.512491502"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/stainwarpy/register/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: STAINWARPY_REGISTER {
ext.args = params.modules_args ?: ''
}
}