From c1ed83ff3ea2e191989374f8e580aa655a5ec7e4 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Fri, 17 Apr 2026 17:36:57 +0200 Subject: [PATCH 01/15] [WIP] creation module BET for invivo --- assets/Docker/brain_extraction.py | 30 +++++++++++++++++ modules/local/mouse/bet/environment.yml | 3 ++ modules/local/mouse/bet/main.nf | 42 +++++++++++++++++++++++ modules/local/mouse/bet/meta.yml | 45 +++++++++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 assets/Docker/brain_extraction.py create mode 100644 modules/local/mouse/bet/environment.yml create mode 100644 modules/local/mouse/bet/main.nf create mode 100755 modules/local/mouse/bet/meta.yml diff --git a/assets/Docker/brain_extraction.py b/assets/Docker/brain_extraction.py new file mode 100644 index 0000000..5be1f5e --- /dev/null +++ b/assets/Docker/brain_extraction.py @@ -0,0 +1,30 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +Extract the brain mask from an anatomical image using ants and antspynet. +""" + +import argparse +import os + +import ants +import antspynet +import argparse +from antspynet import mouse_brain_extraction + +parser = argparse.ArgumentParser(description="") +parser.add_argument('input_anat', type=str, help="Path to the anatomical image.") +parser.add_argument('output_mask', type=str, help="Path to the output mask file.") + +args = parser.parse_args() + +filename_input=args.input_anat +filename_output=args.output_mask + +mri_image = ants.image_read(filename_input) + +output = mouse_brain_extraction(mri_image,modality="t2") +ants.image_write(output,filename_output) + + diff --git a/modules/local/mouse/bet/environment.yml b/modules/local/mouse/bet/environment.yml new file mode 100644 index 0000000..054a77f --- /dev/null +++ b/modules/local/mouse/bet/environment.yml @@ -0,0 +1,3 @@ +channels: [] +dependencies: [] +name: "mouse_bet" diff --git a/modules/local/mouse/bet/main.nf b/modules/local/mouse/bet/main.nf new file mode 100644 index 0000000..218a13e --- /dev/null +++ b/modules/local/mouse/bet/main.nf @@ -0,0 +1,42 @@ +process MOUSE_BET { + label 'process_high' + + container "scilus/scilpy:dev" + + input: + tuple val(meta), path(anat) + output: + tuple val(meta), path("*__mask.nii.gz") , emit: mask + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + + """ + + brain_extraction.py $anat ${prefix}__mask.nii.gz + fslmaths ${prefix}__mask.nii.gz -bin ${prefix}__mask.nii.gz + scil_volume_math convert ${prefix}__mask.nii.gz ${prefix}__mask.nii.gz -f --data_type int8 + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + END_VERSIONS + """ + + stub: + """ + fslmaths + scil_volume_math -h + + touch all__stats.json + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + END_VERSIONS + """ +} \ No newline at end of file diff --git a/modules/local/mouse/bet/meta.yml b/modules/local/mouse/bet/meta.yml new file mode 100755 index 0000000..b5358d4 --- /dev/null +++ b/modules/local/mouse/bet/meta.yml @@ -0,0 +1,45 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/scilus/nf-neuro/main/modules/meta-schema.json +name: "preproc_singleeddy" +description: Apply Eddy (and Topup if already run) +keywords: + - BET + - T1 + - eddy +tools: + - "scilpy": + description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox." + homepage: "https://github.com/scilus/scilpy.git" + - "FSL": + description: "FSL Toolbox and Scilpy Toolbox" + homepage: "https://fsl.fmrib.ox.ac.uk/fsl/fslwiki" +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - anat: + type: file + description: Anat Nifti image + pattern: "*.{nii,nii.gz}" + + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - mask: + type: file + description: mask brain-extracted + pattern: "*__mask.{nii,nii.gz}" + + +authors: + - "@EliseCos" \ No newline at end of file From 3e121385cfaf55d96f81663737eb759723466f69 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Fri, 17 Apr 2026 20:07:41 +0200 Subject: [PATCH 02/15] [WIP] add .config + docker --- assets/Docker/Dockerfile | 3 +++ main.nf | 18 +++++++++++++++++- modules/local/mouse/bet/main.nf | 4 ++-- nextflow.config | 3 +++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/assets/Docker/Dockerfile b/assets/Docker/Dockerfile index 18237a0..c6e7d71 100644 --- a/assets/Docker/Dockerfile +++ b/assets/Docker/Dockerfile @@ -28,6 +28,9 @@ RUN chmod 777 /ANO_taxonomy_EC_V4.csv COPY mouse_extract_masks.py /usr/local/bin/ RUN chmod 777 /usr/local/bin/mouse_extract_masks.py +COPY brain_extraction.py /usr/local/bin/ +RUN chmod 777 /usr/local/bin/brain_extraction.py + WORKDIR / ADD atlas.tar.gz / diff --git a/main.nf b/main.nf index e48f43b..cfb6a0f 100644 --- a/main.nf +++ b/main.nf @@ -3,6 +3,7 @@ include { DENOISING_MPPCA } from './modules/nf-neuro/denoising/mppca/main.nf' include { PREPROC_SINGLEEDDY } from './modules/local/preproc/singleeddy/main.nf' include { UTILS_EXTRACTB0 } from './modules/nf-neuro/utils/extractb0/main.nf' include { NNUNET } from './subworkflows/local/nnunet/' +include { MOUSE_BET } from './modules/local/mouse/bet/main.nf' include { MOUSE_N4 } from './modules/local/mouse/n4/main.nf' include { IMAGE_RESAMPLE as RESAMPLE_DWI} from './modules/nf-neuro/image/resample/main.nf' include { IMAGE_RESAMPLE as RESAMPLE_MASK} from './modules/nf-neuro/image/resample/main.nf' @@ -57,6 +58,10 @@ workflow get_data { .map { mask_file -> def sid = mask_file.parent.name [[id: sid], mask_file] } + anat_channel = Channel.fromPath("$input/**/*anat.nii.gz") + .map { anat_file -> def sid = anat_file.parent.name + [[id: sid], anat_file] } + template_channel = Channel.fromPath("$projectDir/assets/reference_rgb_mqc.png") lut_channel = Channel.of([ @@ -68,6 +73,7 @@ workflow get_data { emit: dwi = dwi_channel mask = mask_channel + anat = anat_channel template_rgb = template_channel lut = lut_channel } @@ -105,6 +111,7 @@ workflow { log.warn('Using the output from the preqc module is highly experimental. Please be careful.') ch_after_preqc = PRE_QC.out.dwi bvs_after_preqc = PRE_QC.out.bvs + } else { ch_after_preqc = Channel.empty() @@ -136,7 +143,16 @@ workflow { else { ch_after_eddy = ch_eddy } - + + if (params.invivo){ + MOUSE_BET(data.anat) + ch_after_eddy = ch_eddy.join( + MOUSE_BET.out.mask) + } + else { + ch_after_eddy = ch_eddy + } + UTILS_EXTRACTB0(ch_after_eddy) ch_nnunet = ch_after_eddy.join(UTILS_EXTRACTB0.out.b0) .join(data.mask, by: 0, remainder: true) diff --git a/modules/local/mouse/bet/main.nf b/modules/local/mouse/bet/main.nf index 218a13e..c5ac737 100644 --- a/modules/local/mouse/bet/main.nf +++ b/modules/local/mouse/bet/main.nf @@ -13,10 +13,10 @@ process MOUSE_BET { task.ext.when == null || task.ext.when script: - def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" """ - + brain_extraction.py $anat ${prefix}__mask.nii.gz fslmaths ${prefix}__mask.nii.gz -bin ${prefix}__mask.nii.gz scil_volume_math convert ${prefix}__mask.nii.gz ${prefix}__mask.nii.gz -f --data_type int8 diff --git a/nextflow.config b/nextflow.config index a5f9674..e18dbc3 100644 --- a/nextflow.config +++ b/nextflow.config @@ -14,6 +14,9 @@ params { // Eddy run_eddy = true processes = 10 + + // Invivo + invivo = false // N4 run_n4 = true From 75ab998b52c6172a398f350ae9016459fe5e350c Mon Sep 17 00:00:00 2001 From: EliseCos Date: Fri, 24 Apr 2026 17:40:03 +0200 Subject: [PATCH 03/15] [WIP] add new container --- modules/local/mouse/bet/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/local/mouse/bet/main.nf b/modules/local/mouse/bet/main.nf index c5ac737..c1ec46f 100644 --- a/modules/local/mouse/bet/main.nf +++ b/modules/local/mouse/bet/main.nf @@ -1,7 +1,7 @@ process MOUSE_BET { label 'process_high' - container "scilus/scilpy:dev" + container "scilus/antspynet:dev" input: tuple val(meta), path(anat) @@ -17,7 +17,7 @@ process MOUSE_BET { """ - brain_extraction.py $anat ${prefix}__mask.nii.gz + antsMouseBrainExtraction $anat ${prefix}__mask.nii.gz fslmaths ${prefix}__mask.nii.gz -bin ${prefix}__mask.nii.gz scil_volume_math convert ${prefix}__mask.nii.gz ${prefix}__mask.nii.gz -f --data_type int8 From 9fe23f3cbf3669674ff69bcf77028b9225fc6adb Mon Sep 17 00:00:00 2001 From: EliseCos Date: Mon, 27 Apr 2026 15:03:44 +0200 Subject: [PATCH 04/15] [ENH] update container --- modules/local/mouse/bet/main.nf | 3 --- nextflow.config | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/local/mouse/bet/main.nf b/modules/local/mouse/bet/main.nf index c1ec46f..5d679e9 100644 --- a/modules/local/mouse/bet/main.nf +++ b/modules/local/mouse/bet/main.nf @@ -16,7 +16,6 @@ process MOUSE_BET { def prefix = task.ext.prefix ?: "${meta.id}" """ - antsMouseBrainExtraction $anat ${prefix}__mask.nii.gz fslmaths ${prefix}__mask.nii.gz -bin ${prefix}__mask.nii.gz scil_volume_math convert ${prefix}__mask.nii.gz ${prefix}__mask.nii.gz -f --data_type int8 @@ -32,8 +31,6 @@ process MOUSE_BET { fslmaths scil_volume_math -h - touch all__stats.json - cat <<-END_VERSIONS > versions.yml "${task.process}": scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) diff --git a/nextflow.config b/nextflow.config index e18dbc3..2780da2 100644 --- a/nextflow.config +++ b/nextflow.config @@ -267,6 +267,11 @@ process { ] } + withName: "MOUSE_BET" { + container = 'scilus/antspynet:dev' + containerOptions = '--entrypoint ""' + } + withName: "UTILS_EXTRACTB0" { ext.b0_threshold = params.b0_threshold } From a0c8cb0ea031f4832c0b8eb09e021b696c8b046f Mon Sep 17 00:00:00 2001 From: EliseCos Date: Tue, 28 Apr 2026 20:33:39 +0200 Subject: [PATCH 05/15] [WIP] add subworkflow BET for in vivo Co-authored-by: Copilot --- main.nf | 11 ++-- .../{bet => brainextraction}/environment.yml | 0 .../mouse/{bet => brainextraction}/main.nf | 5 +- .../mouse/{bet => brainextraction}/meta.yml | 5 +- .../local/mouse/convertbet/environment.yml | 3 ++ modules/local/mouse/convertbet/main.nf | 48 ++++++++++++++++++ modules/local/mouse/convertbet/meta.yml | 44 ++++++++++++++++ modules/local/mouse/convertjson/main.nf | 1 + .../local/mouse/preparebet/environment.yml | 3 ++ modules/local/mouse/preparebet/main.nf | 40 +++++++++++++++ modules/local/mouse/preparebet/meta.yml | 40 +++++++++++++++ nextflow.config | 3 +- subworkflows/.DS_Store | Bin 0 -> 6148 bytes subworkflows/local/bet/main.nf | 27 ++++++++++ 14 files changed, 217 insertions(+), 13 deletions(-) rename modules/local/mouse/{bet => brainextraction}/environment.yml (100%) rename modules/local/mouse/{bet => brainextraction}/main.nf (82%) rename modules/local/mouse/{bet => brainextraction}/meta.yml (91%) create mode 100644 modules/local/mouse/convertbet/environment.yml create mode 100644 modules/local/mouse/convertbet/main.nf create mode 100755 modules/local/mouse/convertbet/meta.yml create mode 100644 modules/local/mouse/preparebet/environment.yml create mode 100644 modules/local/mouse/preparebet/main.nf create mode 100755 modules/local/mouse/preparebet/meta.yml create mode 100644 subworkflows/.DS_Store create mode 100644 subworkflows/local/bet/main.nf diff --git a/main.nf b/main.nf index cfb6a0f..587e715 100644 --- a/main.nf +++ b/main.nf @@ -3,7 +3,7 @@ include { DENOISING_MPPCA } from './modules/nf-neuro/denoising/mppca/main.nf' include { PREPROC_SINGLEEDDY } from './modules/local/preproc/singleeddy/main.nf' include { UTILS_EXTRACTB0 } from './modules/nf-neuro/utils/extractb0/main.nf' include { NNUNET } from './subworkflows/local/nnunet/' -include { MOUSE_BET } from './modules/local/mouse/bet/main.nf' +include { BET } from './subworkflows/local/bet/main.nf' include { MOUSE_N4 } from './modules/local/mouse/n4/main.nf' include { IMAGE_RESAMPLE as RESAMPLE_DWI} from './modules/nf-neuro/image/resample/main.nf' include { IMAGE_RESAMPLE as RESAMPLE_MASK} from './modules/nf-neuro/image/resample/main.nf' @@ -143,14 +143,15 @@ workflow { else { ch_after_eddy = ch_eddy } - + + ch_bet = data.anat if (params.invivo){ - MOUSE_BET(data.anat) + BET(ch_bet) ch_after_eddy = ch_eddy.join( - MOUSE_BET.out.mask) + BET.out.mask) } else { - ch_after_eddy = ch_eddy + ch_after_eddy = ch_eddy } UTILS_EXTRACTB0(ch_after_eddy) diff --git a/modules/local/mouse/bet/environment.yml b/modules/local/mouse/brainextraction/environment.yml similarity index 100% rename from modules/local/mouse/bet/environment.yml rename to modules/local/mouse/brainextraction/environment.yml diff --git a/modules/local/mouse/bet/main.nf b/modules/local/mouse/brainextraction/main.nf similarity index 82% rename from modules/local/mouse/bet/main.nf rename to modules/local/mouse/brainextraction/main.nf index 5d679e9..04bd79f 100644 --- a/modules/local/mouse/bet/main.nf +++ b/modules/local/mouse/brainextraction/main.nf @@ -1,4 +1,5 @@ -process MOUSE_BET { +process MOUSE_BRAINEXTRACTION { + tag "$meta.id" label 'process_high' container "scilus/antspynet:dev" @@ -17,8 +18,6 @@ process MOUSE_BET { """ antsMouseBrainExtraction $anat ${prefix}__mask.nii.gz - fslmaths ${prefix}__mask.nii.gz -bin ${prefix}__mask.nii.gz - scil_volume_math convert ${prefix}__mask.nii.gz ${prefix}__mask.nii.gz -f --data_type int8 cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/local/mouse/bet/meta.yml b/modules/local/mouse/brainextraction/meta.yml similarity index 91% rename from modules/local/mouse/bet/meta.yml rename to modules/local/mouse/brainextraction/meta.yml index b5358d4..f6c6a88 100755 --- a/modules/local/mouse/bet/meta.yml +++ b/modules/local/mouse/brainextraction/meta.yml @@ -1,11 +1,10 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/scilus/nf-neuro/main/modules/meta-schema.json -name: "preproc_singleeddy" -description: Apply Eddy (and Topup if already run) +name: "brainextraction" +description: Extraction of the brain from anatomical images using BET keywords: - BET - T1 - - eddy tools: - "scilpy": description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox." diff --git a/modules/local/mouse/convertbet/environment.yml b/modules/local/mouse/convertbet/environment.yml new file mode 100644 index 0000000..b92d504 --- /dev/null +++ b/modules/local/mouse/convertbet/environment.yml @@ -0,0 +1,3 @@ +channels: [] +dependencies: [] +name: "mouse_convertbet" diff --git a/modules/local/mouse/convertbet/main.nf b/modules/local/mouse/convertbet/main.nf new file mode 100644 index 0000000..aebb95f --- /dev/null +++ b/modules/local/mouse/convertbet/main.nf @@ -0,0 +1,48 @@ +process MOUSE_CONVERTBET { + tag "$meta.id" + label 'process_low' + + container "scilus/scilus:2.2.0" + + input: + tuple val(meta), path(image) + output: + tuple val(meta), path("*_mask.nii.gz") , emit: mask + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + def nb_vox = task.ext.nb_vox ?: "" + """ + fslmaths ${image} -bin ${prefix}_mask.nii.gz + + scil_volume_math erosion ${prefix}_mask.nii.gz $nb_vox ${prefix}_mask.nii.gz --data_type uint8 -f + ImageMath 3 ${prefix}_mask.nii.gz GetLargestComponent ${prefix}_mask.nii.gz + scil_volume_math dilation ${prefix}_mask.nii.gz $nb_vox ${prefix}_mask.nii.gz --data_type uint8 -f + ImageMath 3 ${prefix}_mask.nii.gz FillHoles ${prefix}_mask.nii.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + fslmaths + scil_volume_math -h + ImageMath + + touch ${prefix}_mask.nii.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p') + END_VERSIONS + """ +} \ No newline at end of file diff --git a/modules/local/mouse/convertbet/meta.yml b/modules/local/mouse/convertbet/meta.yml new file mode 100755 index 0000000..fc7e4b5 --- /dev/null +++ b/modules/local/mouse/convertbet/meta.yml @@ -0,0 +1,44 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/scilus/nf-neuro/main/modules/meta-schema.json +name: "mouse_convertjson" +description: Convert stats to JSON +keywords: + - stats + - convert +tools: + - "scilpy": + description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox." + homepage: "https://github.com/scilus/scilpy.git" +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - stats: + type: list + description: DWI Nifti image + pattern: "*.{nii,nii.gz}" + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - stats_json: + type: file + description: File with stats + pattern: "stats_reorganized.json" + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@EliseCos" \ No newline at end of file diff --git a/modules/local/mouse/convertjson/main.nf b/modules/local/mouse/convertjson/main.nf index 5702964..f112f1a 100644 --- a/modules/local/mouse/convertjson/main.nf +++ b/modules/local/mouse/convertjson/main.nf @@ -25,6 +25,7 @@ process MOUSE_CONVERTJSON { """ stub: + def prefix = task.ext.prefix ?: "${meta.id}" """ touch ${prefix}__stats_reorganized.json diff --git a/modules/local/mouse/preparebet/environment.yml b/modules/local/mouse/preparebet/environment.yml new file mode 100644 index 0000000..9e99afe --- /dev/null +++ b/modules/local/mouse/preparebet/environment.yml @@ -0,0 +1,3 @@ +channels: [] +dependencies: [] +name: "mouse_preparebet" diff --git a/modules/local/mouse/preparebet/main.nf b/modules/local/mouse/preparebet/main.nf new file mode 100644 index 0000000..e4c8759 --- /dev/null +++ b/modules/local/mouse/preparebet/main.nf @@ -0,0 +1,40 @@ +process MOUSE_PREPAREBET { + tag "$meta.id" + label 'process_high' + + container "scilus/scilus:2.2.0" + + input: + tuple val(meta), path(image) + output: + tuple val(meta), path("*_n4_second.nii.gz") , emit: betready + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + + N4BiasFieldCorrection -d 3 -i ${image} -o ${prefix}__n4_first.nii.gz -s 4 -c [20x20x10,1e-6] + N4BiasFieldCorrection -d 3 -i ${prefix}__n4_first.nii.gz -o ${prefix}__n4_second.nii.gz -s 2 -c [30x20x10,1e-6] + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + N4BiasFieldCorrection -h + + touch ${prefix}__n4_second.nii.gz + + cat <<-END_VERSIONS > versions.yml + ants: \$(N4BiasFieldCorrection --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') + END_VERSIONS + """ +} diff --git a/modules/local/mouse/preparebet/meta.yml b/modules/local/mouse/preparebet/meta.yml new file mode 100755 index 0000000..2ab9ed4 --- /dev/null +++ b/modules/local/mouse/preparebet/meta.yml @@ -0,0 +1,40 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/scilus/nf-neuro/main/modules/meta-schema.json +name: "preparebet" +description: Prepare anatomical images for brain extraction with BET +keywords: + - volume + - mask +tools: + - "scilpy": + description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox." + homepage: "https://github.com/scilus/scilpy.git" +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - anat: + type: list + description: Anat Nifti image + pattern: "*.{nii,nii.gz}" + + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@EliseCos" \ No newline at end of file diff --git a/nextflow.config b/nextflow.config index 2780da2..0a09354 100644 --- a/nextflow.config +++ b/nextflow.config @@ -268,8 +268,7 @@ process { } withName: "MOUSE_BET" { - container = 'scilus/antspynet:dev' - containerOptions = '--entrypoint ""' + ext.nb_vox = 3 } withName: "UTILS_EXTRACTB0" { diff --git a/subworkflows/.DS_Store b/subworkflows/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..806193f8fc10dc7faa51772381bda09350c1dae8 GIT binary patch literal 6148 zcmeHK%}T>S5Z<+|O({YS3VK`cS}+A`DPBUYFJMFuDm5`hgE3p0)Er77cYPsW#OHBl zcLOa3k0N#kcE8#A+0A^A{b7vp;XLdzW;4btXowt@3PE$FYs&;9ay3UB9cSNt>TXw`^ za6AD0#91y|*52XK>Baateo5q;W|9NtN_GsE@D9pKNw3~4iDmK#)-t1vBqRoi0b+m{ z*hmJa<1$2B%APR%7!9pW=K)6l? z)T!J&F}O|#yD)LC!9t@>XI!le^O%*(#|u}hgI%a_#$Aon69dG+Is-L5wDJ5uhhL`h zk-wfoBVvFU_-738`p6p%p(t~?Vh;t1V V8gUl1t8_rR2q;3RBL;qffiF(zOAP=3 literal 0 HcmV?d00001 diff --git a/subworkflows/local/bet/main.nf b/subworkflows/local/bet/main.nf new file mode 100644 index 0000000..be97e8f --- /dev/null +++ b/subworkflows/local/bet/main.nf @@ -0,0 +1,27 @@ +include { MOUSE_PREPAREBET } from '../../../modules/local/mouse/preparebet/main.nf' +include { MOUSE_BRAINEXTRACTION } from '../../../modules/local/mouse/brainextraction/main.nf' +include { MOUSE_CONVERTBET } from '../../../modules/local/mouse/convertbet/main.nf' + +workflow BET { + + take: + ch_bet // channel: [ val(meta), dwi, bval, b0, mask] + + main: + + ch_versions = Channel.empty() + ch_multiqc_files = Channel.empty() + + + MOUSE_PREPAREBET(ch_bet) + + MOUSE_BRAINEXTRACTION(MOUSE_PREPAREBET.out.betready) + + MOUSE_CONVERTBET(MOUSE_BRAINEXTRACTION.out.mask) + + + emit: + mask = MOUSE_CONVERTBET.out.mask // channel: [ val(meta), mask ] + mqc = ch_multiqc_files // channel: [ val(meta), mqc ] + versions = ch_versions // channel: [ versions.yml ] +} From fffc8fd042be9c07c1081663de131e6cf05449e6 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Wed, 29 Apr 2026 17:42:29 +0200 Subject: [PATCH 06/15] [ENH] adapt to masks from different sources Co-authored-by: Copilot --- main.nf | 72 ++++++++++++++++---------- modules/local/mouse/preparebet/main.nf | 4 +- nextflow.config | 9 ++++ 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/main.nf b/main.nf index 587e715..e1fa1ca 100644 --- a/main.nf +++ b/main.nf @@ -37,13 +37,17 @@ workflow get_data { log.info "" log.info " [input]" log.info " ├-- S1" - log.info " | ├-- *dwi.nii.gz" log.info " | ├-- *dwi.bval" - log.info " | └-- *dwi.bvec" + log.info " | ├-- *dwi.bvec" + log.info " | ├-- *dwi.nii.gz" + log.info " | ├-- *anat.nii.gz (optional)" + log.info " | └-- *mask.nii.gz (optional)" log.info " └-- S2" - log.info " ├-- *dwi.nii.gz" - log.info " ├-- *dwi.bval" - log.info " └-- *dwi.bvec" + log.info " ├-- *dwi.bval" + log.info " ├-- *dwi.bvec" + log.info " ├-- *dwi.nii.gz" + log.info " ├-- *anat.nii.gz (optional)" + log.info " └-- *mask.nii.gz (optional)" log.info "" log.info "" error "Please resubmit your command with the previous file structure." @@ -102,6 +106,8 @@ workflow { } ch_ref_rgb = data.template_rgb ch_lut = data.lut + ch_bet = data.anat + ch_mask = Channel.empty() if ( params.run_preqc ) { PRE_QC(ch_dwi_bvalbvec.dwi.join(ch_dwi_bvalbvec.bvs_files).combine(ch_ref_rgb)) @@ -144,30 +150,40 @@ workflow { ch_after_eddy = ch_eddy } - ch_bet = data.anat - if (params.invivo){ + UTILS_EXTRACTB0(ch_after_eddy) + + if (params.invivo) { BET(ch_bet) - ch_after_eddy = ch_eddy.join( - BET.out.mask) + ch_mask = BET.out.mask } else { - ch_after_eddy = ch_eddy - } + ch_eddy_with_optional_mask = ch_after_eddy + .join(data.mask, by: 0, remainder: true) - UTILS_EXTRACTB0(ch_after_eddy) - ch_nnunet = ch_after_eddy.join(UTILS_EXTRACTB0.out.b0) - .join(data.mask, by: 0, remainder: true) - .map { meta, dwi, bval, bvec, b0, mask -> - [meta, dwi, bval, b0, mask ?: [ ]]} // Use empty list if mask is null + ch_mask_split = ch_eddy_with_optional_mask + .branch { meta, dwi, bval, bvec, mask -> + with_mask: mask != null + no_mask: mask == null} + + ch_mask_from_input = ch_mask_split.with_mask + .map { meta, dwi, bval, bvec, mask -> + tuple(meta, mask)} + + ch_nnunet = ch_mask_split.no_mask + .join(UTILS_EXTRACTB0.out.b0) + .map { meta, dwi, bval, bvec, mask, b0 -> + tuple(meta, dwi, bval, b0, [])} - NNUNET(ch_nnunet) + NNUNET(ch_nnunet) + ch_mask = ch_mask_from_input.mix(NNUNET.out.mask) + } if ( params.run_n4 ) { ch_N4 = ch_after_eddy .map{ meta, dwi, _bval, _bvec -> tuple(meta, dwi)} .join(UTILS_EXTRACTB0.out.b0) - .join(NNUNET.out.mask) + .join(ch_mask) MOUSE_N4(ch_N4) ch_after_n4 = MOUSE_N4.out.dwi_n4 } @@ -178,7 +194,7 @@ workflow { if ( params.run_resampling ) { RESAMPLE_DWI(ch_after_n4.map{ meta, dwi -> [meta, dwi, []] }) // Add an empty list for the optional reference image - RESAMPLE_MASK(NNUNET.out.mask.map{ meta, mask -> [meta, mask, []] }) + RESAMPLE_MASK(ch_mask.map{ meta, mask -> [meta, mask, []] }) IMAGE_CONVERT(RESAMPLE_MASK.out.image) dwi_after_resample = RESAMPLE_DWI.out.image @@ -186,7 +202,7 @@ workflow { } else { dwi_after_resample = ch_after_n4 - IMAGE_CONVERT(NNUNET.out.mask) + IMAGE_CONVERT(ch_mask) mask_after_resample = IMAGE_CONVERT.out.image } @@ -204,13 +220,15 @@ workflow { ch_multiqc_files = ch_multiqc_files.mix(RECONST_DTIMETRICS.out.mqc) /* FODF */ - RECONST_FRF(ch_for_reconst.map{ it + [[], [], []]}) - ch_for_reconst_fodf = ch_for_reconst - .join(RECONST_DTIMETRICS.out.fa) - .join(RECONST_DTIMETRICS.out.md) - .join(RECONST_FRF.out.frf) - .map{ it + [[], []]} - RECONST_FODF(ch_for_reconst_fodf) + if ( params.run_fodf_metrics ) { + RECONST_FRF(ch_for_reconst.map{ it + [[], [], []]}) + ch_for_reconst_fodf = ch_for_reconst + .join(RECONST_DTIMETRICS.out.fa) + .join(RECONST_DTIMETRICS.out.md) + .join(RECONST_FRF.out.frf) + .map{ it + [[], []]} + RECONST_FODF(ch_for_reconst_fodf) + } /* QBALL */ RECONST_QBALL(ch_for_reconst) diff --git a/modules/local/mouse/preparebet/main.nf b/modules/local/mouse/preparebet/main.nf index e4c8759..365730f 100644 --- a/modules/local/mouse/preparebet/main.nf +++ b/modules/local/mouse/preparebet/main.nf @@ -5,7 +5,7 @@ process MOUSE_PREPAREBET { container "scilus/scilus:2.2.0" input: - tuple val(meta), path(image) + tuple val(meta), path(anat) output: tuple val(meta), path("*_n4_second.nii.gz") , emit: betready path "versions.yml" , emit: versions @@ -17,7 +17,7 @@ process MOUSE_PREPAREBET { def prefix = task.ext.prefix ?: "${meta.id}" """ - N4BiasFieldCorrection -d 3 -i ${image} -o ${prefix}__n4_first.nii.gz -s 4 -c [20x20x10,1e-6] + N4BiasFieldCorrection -d 3 -i ${anat} -o ${prefix}__n4_first.nii.gz -s 4 -c [20x20x10,1e-6] N4BiasFieldCorrection -d 3 -i ${prefix}__n4_first.nii.gz -o ${prefix}__n4_second.nii.gz -s 2 -c [30x20x10,1e-6] diff --git a/nextflow.config b/nextflow.config index 0a09354..b1432ec 100644 --- a/nextflow.config +++ b/nextflow.config @@ -31,6 +31,7 @@ params { nvox_min = 100 // FODF || QBALL + run_fodf_metrics = true use_fodf_for_tracking = false sh_order = 6 min_fodf_value = 1000 @@ -228,6 +229,14 @@ profiles { pre_qc { params.run_preqc = true + params.use_preqc = true + } + + invivo { + params.invivo = true + params.run_resampling = false + params.run_fodf_metrics = false + params.run_tracking = false } } From 71408e581dffce40a1ede5c9889c55cdd5372041 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Thu, 30 Apr 2026 11:59:31 +0000 Subject: [PATCH 07/15] [ENH] correct main.nf + .config --- main.nf | 33 ++++++++++++--------------------- nextflow.config | 3 +++ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/main.nf b/main.nf index e1fa1ca..213a179 100644 --- a/main.nf +++ b/main.nf @@ -149,34 +149,25 @@ workflow { else { ch_after_eddy = ch_eddy } - - UTILS_EXTRACTB0(ch_after_eddy) if (params.invivo) { BET(ch_bet) ch_mask = BET.out.mask } + else if ( params.data_masked ) { + ch_mask = data.mask + } else { - ch_eddy_with_optional_mask = ch_after_eddy - .join(data.mask, by: 0, remainder: true) - - ch_mask_split = ch_eddy_with_optional_mask - .branch { meta, dwi, bval, bvec, mask -> - with_mask: mask != null - no_mask: mask == null} - - ch_mask_from_input = ch_mask_split.with_mask - .map { meta, dwi, bval, bvec, mask -> - tuple(meta, mask)} - - ch_nnunet = ch_mask_split.no_mask - .join(UTILS_EXTRACTB0.out.b0) - .map { meta, dwi, bval, bvec, mask, b0 -> - tuple(meta, dwi, bval, b0, [])} - + UTILS_EXTRACTB0(ch_after_eddy) + ch_nnunet = ch_after_eddy.join(UTILS_EXTRACTB0.out.b0) + .join(data.mask, by: 0, remainder: true) + .map { meta, dwi, bval, bvec, b0, mask -> + [meta, dwi, bval, b0, mask ?: [ ]]} + NNUNET(ch_nnunet) - ch_mask = ch_mask_from_input.mix(NNUNET.out.mask) - } + + ch_mask = NNUNET.out.mask + } if ( params.run_n4 ) { ch_N4 = ch_after_eddy diff --git a/nextflow.config b/nextflow.config index b1432ec..056e928 100644 --- a/nextflow.config +++ b/nextflow.config @@ -15,6 +15,9 @@ params { run_eddy = true processes = 10 + // Masked + data_masked = false + // Invivo invivo = false From f45747a4b47de190dc74a5ee10b60c2a3d553ca0 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Mon, 4 May 2026 11:11:19 +0000 Subject: [PATCH 08/15] fix module b0 --- main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.nf b/main.nf index 213a179..9cf520e 100644 --- a/main.nf +++ b/main.nf @@ -149,6 +149,7 @@ workflow { else { ch_after_eddy = ch_eddy } + UTILS_EXTRACTB0(ch_after_eddy) if (params.invivo) { BET(ch_bet) @@ -158,7 +159,6 @@ workflow { ch_mask = data.mask } else { - UTILS_EXTRACTB0(ch_after_eddy) ch_nnunet = ch_after_eddy.join(UTILS_EXTRACTB0.out.b0) .join(data.mask, by: 0, remainder: true) .map { meta, dwi, bval, bvec, b0, mask -> From 58e76b26ff8268903285fa239669e3bcc1cb4b2a Mon Sep 17 00:00:00 2001 From: EliseCos Date: Mon, 4 May 2026 16:47:01 +0200 Subject: [PATCH 09/15] remove docker files --- assets/Docker/Dockerfile | 40 ------------------------------- assets/Docker/brain_extraction.py | 30 ----------------------- 2 files changed, 70 deletions(-) delete mode 100644 assets/Docker/Dockerfile delete mode 100644 assets/Docker/brain_extraction.py diff --git a/assets/Docker/Dockerfile b/assets/Docker/Dockerfile deleted file mode 100644 index c6e7d71..0000000 --- a/assets/Docker/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -FROM scilus/scilus:2.2.0 - -USER root - -WORKDIR / -RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - build-essential gcc bc\ - zlib1g-dev \ - clinfo \ - git \ - libblas-dev \ - libfreetype6-dev \ - liblapack-dev \ - locales \ - imagemagick && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR / - -COPY maskbackgroundnoise /usr/bin/ -COPY ants_generate_iterations.py /ants/bin/ -RUN chmod 777 /ants/bin/ants_generate_iterations.py - -COPY ANO_taxonomy_EC_V4.csv / -RUN chmod 777 /ANO_taxonomy_EC_V4.csv - -COPY mouse_extract_masks.py /usr/local/bin/ -RUN chmod 777 /usr/local/bin/mouse_extract_masks.py - -COPY brain_extraction.py /usr/local/bin/ -RUN chmod 777 /usr/local/bin/brain_extraction.py - -WORKDIR / -ADD atlas.tar.gz / - -ARG NUMBA_CACHE_DIR -ENV NUMBA_CACHE_DIR="/tmp" - -WORKDIR / diff --git a/assets/Docker/brain_extraction.py b/assets/Docker/brain_extraction.py deleted file mode 100644 index 5be1f5e..0000000 --- a/assets/Docker/brain_extraction.py +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Extract the brain mask from an anatomical image using ants and antspynet. -""" - -import argparse -import os - -import ants -import antspynet -import argparse -from antspynet import mouse_brain_extraction - -parser = argparse.ArgumentParser(description="") -parser.add_argument('input_anat', type=str, help="Path to the anatomical image.") -parser.add_argument('output_mask', type=str, help="Path to the output mask file.") - -args = parser.parse_args() - -filename_input=args.input_anat -filename_output=args.output_mask - -mri_image = ants.image_read(filename_input) - -output = mouse_brain_extraction(mri_image,modality="t2") -ants.image_write(output,filename_output) - - From c63eb8f0409aa837002d5bc8cf41b1d76f37d21d Mon Sep 17 00:00:00 2001 From: EliseCos Date: Mon, 4 May 2026 16:49:42 +0200 Subject: [PATCH 10/15] restore dockerfile --- assets/Docker/Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 assets/Docker/Dockerfile diff --git a/assets/Docker/Dockerfile b/assets/Docker/Dockerfile new file mode 100644 index 0000000..c6e7d71 --- /dev/null +++ b/assets/Docker/Dockerfile @@ -0,0 +1,40 @@ +FROM scilus/scilus:2.2.0 + +USER root + +WORKDIR / +RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential gcc bc\ + zlib1g-dev \ + clinfo \ + git \ + libblas-dev \ + libfreetype6-dev \ + liblapack-dev \ + locales \ + imagemagick && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR / + +COPY maskbackgroundnoise /usr/bin/ +COPY ants_generate_iterations.py /ants/bin/ +RUN chmod 777 /ants/bin/ants_generate_iterations.py + +COPY ANO_taxonomy_EC_V4.csv / +RUN chmod 777 /ANO_taxonomy_EC_V4.csv + +COPY mouse_extract_masks.py /usr/local/bin/ +RUN chmod 777 /usr/local/bin/mouse_extract_masks.py + +COPY brain_extraction.py /usr/local/bin/ +RUN chmod 777 /usr/local/bin/brain_extraction.py + +WORKDIR / +ADD atlas.tar.gz / + +ARG NUMBA_CACHE_DIR +ENV NUMBA_CACHE_DIR="/tmp" + +WORKDIR / From ba4bce2b27a6c8fae3786a328e5ad2dd47314f99 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Mon, 4 May 2026 18:57:11 +0200 Subject: [PATCH 11/15] remove mask nnunet --- assets/Docker/Dockerfile | 3 --- main.nf | 5 ++--- modules/local/mouse/betnnunet/main.nf | 21 ++++++++------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/assets/Docker/Dockerfile b/assets/Docker/Dockerfile index c6e7d71..18237a0 100644 --- a/assets/Docker/Dockerfile +++ b/assets/Docker/Dockerfile @@ -28,9 +28,6 @@ RUN chmod 777 /ANO_taxonomy_EC_V4.csv COPY mouse_extract_masks.py /usr/local/bin/ RUN chmod 777 /usr/local/bin/mouse_extract_masks.py -COPY brain_extraction.py /usr/local/bin/ -RUN chmod 777 /usr/local/bin/brain_extraction.py - WORKDIR / ADD atlas.tar.gz / diff --git a/main.nf b/main.nf index 9cf520e..00e34a5 100644 --- a/main.nf +++ b/main.nf @@ -160,9 +160,8 @@ workflow { } else { ch_nnunet = ch_after_eddy.join(UTILS_EXTRACTB0.out.b0) - .join(data.mask, by: 0, remainder: true) - .map { meta, dwi, bval, bvec, b0, mask -> - [meta, dwi, bval, b0, mask ?: [ ]]} + .map { meta, dwi, bval, bvec, b0 -> + [meta, dwi, bval, b0 ?: [ ]]} NNUNET(ch_nnunet) diff --git a/modules/local/mouse/betnnunet/main.nf b/modules/local/mouse/betnnunet/main.nf index 851b19d..070fb3c 100644 --- a/modules/local/mouse/betnnunet/main.nf +++ b/modules/local/mouse/betnnunet/main.nf @@ -5,7 +5,7 @@ process MOUSE_BETNNUNET { container "scilus/nnunet_bet_mouse:0.1.0_cpu" input: - tuple val(meta), path(dwi), path(b0), path(mask) + tuple val(meta), path(dwi), path(b0) output: tuple val(meta), path("*__mask.nii.gz") , emit: mask path "versions.yml" , emit: versions @@ -17,21 +17,16 @@ process MOUSE_BETNNUNET { def prefix = task.ext.prefix ?: "${meta.id}" """ - if [[ -f "$mask" ]] - then - mv $mask ${prefix}__mask.nii.gz - else export nnUNet_raw="Database/RAW/" export nnUNet_preprocessed="Database/PRE/" export nnUNet_results="Database/RESULTS/" - mkdir -p Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs - ln -s /Database/RAW/Dataset012_ExVivoBrainFSboth/dataset.json Database/RAW/Dataset012_ExVivoBrainFSboth/dataset.json - ln -s /Database/RESULTS Database/RESULTS - mv $b0 Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs/exvivobrain_000_0000.nii.gz - mv $dwi Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs/exvivobrain_000_0001.nii.gz - nnUNetv2_predict -i Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs -o ./ -d 012 -c 3d_fullres -f all -npp 1 -nps 1 -device 'cpu' -tr nnUNetTrainer -chk checkpoint_best.pth - mv exvivobrain_000.nii.gz ${prefix}__mask.nii.gz - fi + mkdir -p Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs + ln -s /Database/RAW/Dataset012_ExVivoBrainFSboth/dataset.json Database/RAW/Dataset012_ExVivoBrainFSboth/dataset.json + ln -s /Database/RESULTS Database/RESULTS + mv $b0 Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs/exvivobrain_000_0000.nii.gz + mv $dwi Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs/exvivobrain_000_0001.nii.gz + nnUNetv2_predict -i Database/RAW/Dataset012_ExVivoBrainFSboth/imagesTs -o ./ -d 012 -c 3d_fullres -f all -npp 1 -nps 1 -device 'cpu' -tr nnUNetTrainer -chk checkpoint_best.pth + mv exvivobrain_000.nii.gz ${prefix}__mask.nii.gz cat <<-END_VERSIONS > versions.yml "${task.process}": From 4b9d7acde6cb3de5f6b8327bb2907f872039c9e5 Mon Sep 17 00:00:00 2001 From: EliseCos <140726377+EliseCos@users.noreply.github.com> Date: Fri, 8 May 2026 19:21:42 +0200 Subject: [PATCH 12/15] Delete subworkflows/.DS_Store --- subworkflows/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 subworkflows/.DS_Store diff --git a/subworkflows/.DS_Store b/subworkflows/.DS_Store deleted file mode 100644 index 806193f8fc10dc7faa51772381bda09350c1dae8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5Z<+|O({YS3VK`cS}+A`DPBUYFJMFuDm5`hgE3p0)Er77cYPsW#OHBl zcLOa3k0N#kcE8#A+0A^A{b7vp;XLdzW;4btXowt@3PE$FYs&;9ay3UB9cSNt>TXw`^ za6AD0#91y|*52XK>Baateo5q;W|9NtN_GsE@D9pKNw3~4iDmK#)-t1vBqRoi0b+m{ z*hmJa<1$2B%APR%7!9pW=K)6l? z)T!J&F}O|#yD)LC!9t@>XI!le^O%*(#|u}hgI%a_#$Aon69dG+Is-L5wDJ5uhhL`h zk-wfoBVvFU_-738`p6p%p(t~?Vh;t1V V8gUl1t8_rR2q;3RBL;qffiF(zOAP=3 From d341d41de0c85818ba2f18f0c72c425fbb099622 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Fri, 8 May 2026 19:23:50 +0200 Subject: [PATCH 13/15] add .gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file From c0f546e2e8d8af75223aad936404e3ff54613e2c Mon Sep 17 00:00:00 2001 From: EliseCos Date: Tue, 12 May 2026 17:05:13 +0000 Subject: [PATCH 14/15] fix output registration --- nextflow.config | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nextflow.config b/nextflow.config index c5d0159..05bffac 100644 --- a/nextflow.config +++ b/nextflow.config @@ -337,7 +337,7 @@ process { ext.atlas_resolution = "" ext.run_qc = true publishDir = [ - path: { "${params.outdir}/${meta.id}/anat/"}, + [ path: { "${params.outdir}/${meta.id}/anat/"}, saveAs: { filename -> if ( filename.contains("ANO.nii.gz") ) { "${meta.id}_atlas-Allen_desc-ANO_dseg.nii.gz"} @@ -346,19 +346,18 @@ process { else if ( filename.contains("0GenericAffine.mat") ) { "${meta.id}_from-Allen_to-dwi_affine.mat"} else if ( filename.contains("1Warp.nii.gz") ) { "${meta.id}_from-Allen_to-dwi_warp.nii.gz"} else if ( filename.contains("1InverseWarp.nii.gz") ) { "${meta.id}_from-dwi_to-Allen_warp.nii.gz"} - else if ( filename.contains("b0.nii.gz") ) { "${meta.id}_desc-process_b0.nii.gz"} else if ( filename.contains("versions.yml") ) { null } else { params.lean_output ? null : filename } - }, - path: { "${params.outdir}/${meta.id}/anat/"}, + } ], + [ path: { "${params.outdir}/${meta.id}/dwi/"}, saveAs: { filename -> if ( filename.contains("b0.nii.gz") ) { "${meta.id}_desc-process_b0.nii.gz"} else if ( filename.contains("versions.yml") ) { null } else { params.lean_output ? null : filename } - } + }] ] } From 1d2a6af6e623e261545fdf67a4d37e1d0ff05c32 Mon Sep 17 00:00:00 2001 From: EliseCos Date: Fri, 15 May 2026 20:21:22 +0200 Subject: [PATCH 15/15] Answer Arnaud's comments --- modules/local/mouse/brainextraction/main.nf | 7 +++---- modules/local/mouse/convertbet/main.nf | 5 ++++- modules/local/mouse/register/main.nf | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/local/mouse/brainextraction/main.nf b/modules/local/mouse/brainextraction/main.nf index 04bd79f..2242f0b 100644 --- a/modules/local/mouse/brainextraction/main.nf +++ b/modules/local/mouse/brainextraction/main.nf @@ -21,18 +21,17 @@ process MOUSE_BRAINEXTRACTION { cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + ants: \$(antsMouseBrainExtraction --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') END_VERSIONS """ stub: """ - fslmaths - scil_volume_math -h + antsMouseBrainExtraction -h cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + ants: \$(antsMouseBrainExtraction --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') END_VERSIONS """ } \ No newline at end of file diff --git a/modules/local/mouse/convertbet/main.nf b/modules/local/mouse/convertbet/main.nf index aebb95f..990d9d2 100644 --- a/modules/local/mouse/convertbet/main.nf +++ b/modules/local/mouse/convertbet/main.nf @@ -26,7 +26,9 @@ process MOUSE_CONVERTBET { cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + scilpy: \$(uv -q -n pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p') + ants: \$(ImageMath --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') END_VERSIONS """ @@ -43,6 +45,7 @@ process MOUSE_CONVERTBET { "${task.process}": scilpy: \$(uv pip -q -n list | grep scilpy | tr -s ' ' | cut -d' ' -f2) fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p') + ants: \$(ImageMath --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') END_VERSIONS """ } \ No newline at end of file diff --git a/modules/local/mouse/register/main.nf b/modules/local/mouse/register/main.nf index 01bfec9..0bf5cd7 100644 --- a/modules/local/mouse/register/main.nf +++ b/modules/local/mouse/register/main.nf @@ -184,8 +184,9 @@ process MOUSE_REGISTRATION { cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: \$(uv -q -n pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + scilpy: \$(uv -q -n pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p') + ants: \$(antsRegistration --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') END_VERSIONS """ @@ -206,9 +207,10 @@ process MOUSE_REGISTRATION { cat <<-END_VERSIONS > versions.yml "${task.process}": - scilpy: \$(uv -q -n pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) + scilpy: \$(uv -q -n pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2) mrtrix: \$(dwidenoise -version 2>&1 | sed -n 's/== dwidenoise \\([0-9.]\\+\\).*/\\1/p') fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p') + ants: \$(antsRegistration --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p') END_VERSIONS """ }